package com.huiquan.analysis.domain;

import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Regis on 15/6/12.
 */
public class Dictionary implements Serializable {
    private static final long serialVersionUID = -3710265311055182708L;
    
    public static final Integer TYPE_SPLIT = 1;
    public static final Integer TYPE_MERGE = 2;
    public static final Integer TYPE_UPDATE_PARAM = 3;
    public static final Integer TYPE_MULTI_SPLIT = 4;

    private Long id;
    private String vocabulary;
    private String dictionary;
    private String userName;
    private Long uid;
    /** 类型：1-短语分拆型，2-句子合并型，3-短语改属型，4-多对多分拆型'. */
    private Integer type;
    private String modifyTime;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getVocabulary() {
        return vocabulary;
    }

    public void setVocabulary(String vocabulary) {
        this.vocabulary = vocabulary;
    }

    public String getDictionary() {
        if (StringUtils.isEmpty(dictionary))
            return "";
        return dictionary;
    }

    public void setDictionary(String dictionary) {
        this.dictionary = dictionary;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Long getUid() {
		return uid;
	}

	public void setUid(Long uid) {
		this.uid = uid;
	}

	public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }

    public List<Vocabulary> getVocabularys() {
        String[] params = getDictionary().split(";");

        List<Vocabulary> vocabularyList = new ArrayList<>();
        for (String param : params) {
            String[] tmp = param.split("_", 3);
            if (tmp.length < 3)
                continue;
            Vocabulary vocabulary = new Vocabulary();
            vocabulary.setVocabulary(tmp[0]);
            vocabulary.setCharacter(tmp[1]);
            vocabulary.setProperty(tmp[2]);

            vocabularyList.add(vocabulary);
        }

        return vocabularyList;

    }
}
